<?php
abstract class Data_Model_DataMapperAbstract
{
	private static $_db = null;
	
	protected function getDb()
	{
		if(is_null(self::$_db))
		{
			self::$_db = Zend_Db_Table::getDefaultAdapter();
		}
		return self::$_db;	
	}
	
	public function save(Data_Model_DomainObjectAbstract $obj)
	{
		if(is_null($obj->getId()))
		{
			$this->_insert($obj);
			
			return $this->getDb()->lastInsertId();
		}
		else {
			$this->_update($obj);
		}
	}
	
	abstract protected function _insert(Data_Model_DomainObjectAbstract $obj);
	
	abstract protected function _update(Data_Model_DomainObjectAbstract $obj);
	
	abstract protected function _populate($data);
	
	/* abstract public static function getInstance(); */
}
